﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Warehouse.DataAccess
{
    public partial class ProductSpecification : CustomeEntity<ProductSpecification>
    {
        public static readonly ProductSpecification Empty = new ProductSpecification()
        {
            ID = 0
        };

        #region Public Static Methods
        public static ProductSpecification GetProductSpecification(int ID)
        {
            using (WarehouseClassesDataContext context = new WarehouseClassesDataContext())
            {
                Console.WriteLine("abc");
                context.Log = Console.Out;
                try
                {
                    return (from t in context.ProductSpecification where t.ID == ID select t).SingleOrDefault();
                }
                finally
                {
                    context.Log.Flush();
                }
            }
        }

        public static ProductSpecification[] GetProductSpecifications()
        {
            return GetList().ToArray();
        }

        public static ProductSpecification[] GetProductSpecifications(int productID)
        {
            return GetList(p => p.ProductID == productID).ToArray();
        }
        #endregion

        protected override System.Linq.Expressions.Expression<Func<ProductSpecification, bool>> GetPredicate()
        {
            return p => p.ID == this.ID;
        }
    }
}
